//企业简历详情基本信息
import React, {Component} from 'react'
import {
    View,
    Text,
    Image,
} from 'react-native';

import {Cresumebasic_Style as styles} from '../../../../styles';
import Icon from 'react-native-vector-icons/Ionicons';
import worktime from '../../../util/worktime';
import {common_url} from "../../../util/fetch";

export default class Cresume_basic extends Component {
    render() {
        return (
            <View style={styles.bas_all}>
                <View style={styles.bas_onetop}>
                    <Image source={
                        this.props.xzResume.resumeIntentField ?
                            {uri: common_url + "uploadImg/" + this.props.xzResume.resumeIntentField}
                            : require('../../../img/app/boy.png')} style={styles.bas_head}/>
                    <View style={styles.bas_left}>

                        <View style={styles.bas_every1}>
                            <Text style={styles.bas_name}>{this.props.xzResume.resumeName}</Text>
                            <Icon
                                name={'md-female'}
                                size={15}
                                color={'#3d9ccc'} style={styles.bas_sex}/>
                        </View>

                        <View style={styles.bas_every2}>
                            <Text style={styles.bas_age}>{this.resumeBirth(this.props.xzResume.resumeBirth)}岁</Text>
                            {/* <Text style={styles.bas_age}>{this.props.xzResume.resumeWorkspace}</Text> */}
                            <Text
                                style={styles.bas_age}>{this.resumeWorkinglife(this.props.xzResume.resumeWorkinglife)}年经验</Text>
                            <Text style={styles.bas_age}>{this.xzResumeEducations(this.props.xzResumeEducations)}</Text>
                        </View>

                        <View style={styles.bas_every3}>
                            <Text style={styles.bas_pos}>{this.props.xzResume.resumePosition}</Text>
                            <Text style={styles.bas_genre}>{this.fieldName(this.props.xzResume.fields, 9)}</Text>
                        </View>

                        <Text style={styles.bas_state}>求职状态：{this.resumeState(this.props.xzResume.resumeState)}</Text>

                    </View>
                </View>


                <View style={styles.bas_onebottom}>
                    <View style={styles.bas_every4}>
                        <Icon
                            name={'md-mail'}
                            size={15}
                            color={'#aeaeae'} style={styles.bas_mail}/>
                        <Text style={styles.bas_text2}>{this.props.xzResume.resumeEmail}</Text>
                    </View>
                    <View style={styles.bas_every4}>
                        <Icon
                            name={'md-phone-portrait'}
                            size={18}
                            color={'#aeaeae'} style={styles.bas_phone}/>
                        <Text style={styles.bas_text2}>{this.props.xzResume.resumePhone}</Text>
                    </View>
                    <View style={styles.bas_every4}>
                        <Icon
                            name={'md-heart'}
                            size={17}
                            color={'#aeaeae'} style={styles.bas_mail}/>
                        <Text style={styles.bas_text2}>{this.resumeMarriage(this.props.xzResume.resumeMarriage)}</Text>
                    </View>
                    <View style={styles.bas_every4}>
                        <Icon
                            name={'md-pin'}
                            size={17}
                            color={'#aeaeae'} style={styles.bas_area}/>
                        <Text style={styles.bas_text2}>{this.props.xzResume.resumeWorkspace}</Text>
                    </View>
                    <View style={styles.bas_every4}>
                        <Icon
                            name={'logo-yen'}
                            size={14}
                            color={'#aeaeae'} style={styles.bas_area}/>
                        <Text style={styles.bas_text2}>{this.props.xzResume.resumeIntentMm}</Text>
                    </View>
                </View>
            </View>
        )
    }

    //当前状态
    resumeState(a) {
        var str = '';
        if (a == '0') {
            str = '未工作';
        } else if (a == '1') {
            str = '在职,考虑新机会';
        } else if (a == '2') {
            str = '离职,正在找工作';
        } else if (a == '3') {
            str = '在职,暂无跳槽打算';
        }
        return str;
    }

    resumeWorkinglife(data) {                                    //计算时间
        let aa = worktime(data).substring(0, 4);
        let bb = worktime(new Date()).substring(0, 4);
        let sj = bb - aa;                    //页面负责运算计算年龄
        return sj
    }

    resumeBirth(data) {                                    //计算时间
        let aa = worktime(data).substring(0, 4);
        let bb = worktime(new Date()).substring(0, 4);
        let sj = bb - aa;                    //页面负责运算计算年龄
        return sj
    }

    //经营领域
    fieldName(List, sl) {
        let arr = '';
        if (List != undefined) {
            let s = sl;
            let length = List.length;
            if (length <= s) {
                s = length;
            }
            for (let i = 0; i < s; i++) {
                if (List[i].fieldType == '2') {
                    arr += List[i].fieldName + '/';
                }
            }
            if (arr.endsWith('/')) {
                arr = arr.substr(0, arr.length - 1);
            }
        }
        return arr;
    }

    //婚姻状况
    resumeMarriage(a) {
        var str = '';
        if (a == '0') {
            str = '未婚';
        } else if (a == '1') {
            str = '已婚';
        } else if (a == '2') {
            str = '保密';
        }
        return str;
    }

    xzResumeEducations(Educations) {
        let arr = '';
        if (Educations != undefined) {
            for (let i = 0; i < Educations.length; i++) {
                if (Educations[i].educationLevel == '博士') {
                    return arr = '博士';
                } else if (Educations[i].educationLevel == '硕士') {
                    return arr = '硕士';
                } else if (Educations[i].educationLevel == '本科') {
                    return arr = '本科';
                } else if (Educations[i].educationLevel == '大专') {
                    return arr = '大专';
                } else if (Educations[i].educationLevel == '中专') {
                    return arr = '中专';
                } else if (Educations[i].educationLevel == '初中') {
                    return arr = '初中';
                }
            }
        } else {
            return arr;
        }
    }
}